package cn.net.vote.util;

import java.util.Comparator;

import com.alibaba.fastjson.JSONObject;


public class JsonComparator implements Comparator<JSONObject>{

	  String dateName = "";
	  public JsonComparator(String dateName){
	    this.dateName = dateName;
	  }
	  @Override
	  public int compare(JSONObject json1, JSONObject json2){
	    String date1 = json1.getString(dateName);
	    String date2 = json2.getString(dateName);
	    if(date1.compareTo(date2) < 0){
	      return 1;
	    }else if(date1.compareTo(date2) >0){
	      return -1;
	    }
	    return 0;
	  }
	}